package pattern.responsibility.example1;

import pattern.responsibility.example1.impl.AddFooter;
import pattern.responsibility.example1.impl.AddHeader;
import pattern.responsibility.example1.impl.ChangeColor;
import pattern.responsibility.example1.impl.EnlargeFont;

public class DocumentFormat {
	private static Format[] solutions = { new EnlargeFont(), new ChangeColor(),
			new AddHeader(), new AddFooter(), };

	public static Document solve(Document line) {
		Document r = line;
		for (int i = 0; i < solutions.length; i++) {
			r = solutions[i].doFormat(r);
			if (r.isSuccessful())
				return r;
		}
		throw new RuntimeException("unsolved: " + line);
	}
}
